package ru.ibragimoff;

import lombok.extern.slf4j.Slf4j;
import ru.ibragimoff.entity.MyEntity;
import ru.ibragimoff.entity.SomeEntity;
import ru.ibragimoff.repository.MyRepository;
import ru.ibragimoff.repository.SomeRepository;
import ru.ibragimoff.repository.resolver.RepositoryResolver;
import ru.ibragimoff.repository.resolver.exception.RepositoryNotFoundException;

@Slf4j
public class App 
{
    public static void main( String[] args ) {
        RepositoryResolver rr = new RepositoryResolver();
        rr.addRepository(new MyRepository());
        rr.addRepository(new SomeRepository());

        MyEntity myEntity;
        SomeEntity someEntity;

        try {
            myEntity = rr.getRepository(MyEntity.class).findById("id1");
            someEntity = rr.getRepository(SomeEntity.class).findById("id2");
        } catch (RepositoryNotFoundException e) {
            log.error(e.getMessage());
            return;
        }

        log.info("{} - {}", myEntity.getClass().getName(), myEntity);
        log.info("{} - {}", someEntity.getClass().getName(), someEntity);
    }
}
